home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume8 / pcmail / part02 < prev    next >
Encoding:
Text File  |  1989-11-03  |  45.4 KB  |  1,298 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v08i110: pcmail part 02 of 08
  3. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  4. Reply-To: markl@oracle.com (Croaker the Physician)
  5.  
  6. Posting-number: Volume 8, Issue 110
  7. Submitted-by: markl@oracle.com (Croaker the Physician)
  8. Archive-name: pcmail/part02
  9.  
  10. #--------------------------------CUT HERE-------------------------------------
  11. #! /bin/sh
  12. #
  13. # This is a shell archive.  Save this into a file, edit it
  14. # and delete all lines above this comment.  Then give this
  15. # file to sh by executing the command "sh file".  The files
  16. # will be extracted into the current directory owned by
  17. # you with default permissions.
  18. #
  19. # The files contained herein are:
  20. #
  21. # -rw-rw-r--  1 markl       32875 Nov  2 07:53 mailhelpab
  22. # -rwxrwxr-x  1 markl        2910 Oct 30 12:18 mh-to-pcmail-export
  23. # -rw-r--r--  1 markl        7448 Oct 30 15:47 nntp.c
  24. #
  25. echo 'x - mailhelpab'
  26. if test -f mailhelpab; then echo 'shar: not overwriting mailhelpab'; else
  27. sed 's/^X//' << '________This_Is_The_END________' > mailhelpab
  28. X
  29. XRead a folder filter type from the minibuffer.  Input completion is
  30. Xpermitted; input defaults to the last filter name given a filter
  31. Xcommand.  Go to the nearest previous message passed by the filter.
  32. X
  33. X
  34. X5.1.3 Attribute Setting Commands
  35. X
  36. Xd: pcmail-delete-message
  37. X
  38. XDelete this message and move to the next interesting message in the
  39. Xmessage subset.  Deleted messages always remain in the folder until
  40. Xthe folder is expunged.  With a prefix argument, delete and move to
  41. Xthe next message in the message subset whether or not it is
  42. Xinteresting.
  43. X
  44. XC-d: pcmail-delete-message-backward
  45. X
  46. XAs above, but move to the nearest previous interesting message after
  47. Xdeletion, rather than the next.
  48. X
  49. XESC C-d: pcmail-delete-subset
  50. X
  51. XDelete all messages in the message subset.  
  52. X
  53. Xi: pcmail-change-message-priority
  54. X
  55. XMessages can be assigned positive numeric priorities; the higher the
  56. Xnumber, the lower the priority and presumably the less important the
  57. Xmessage.  The priority is placed in a "priority:" field in the message
  58. Xheader and used in two places.  First, a folder's contents can be
  59. Xsorted by priority, highest to lowest.  Second, the default
  60. Xinteresting-message hook defines messages with a priority number
  61. Xgreater than or equal to 5 as "uninteresting".  User-defined
  62. Xpigeonhole hooks can also use a message's priority to categorize the
  63. Xmessage.  Pcmail-change-message-priority requests a priority from the
  64. Xminibuffer and assigns the current message that priority.  With a
  65. Xprefix argument, the command deletes the current priority.  Messages
  66. Xwith no priority default to being highest priority.
  67. X
  68. XESC C-i: pcmail-change-priority-subset
  69. X
  70. XAs above, but set all messages in the current subset to the specified
  71. Xpriority. 
  72. X
  73. Xk: pcmail-kill-message-later
  74. X
  75. XRead a date of the form dd-mmm-yy from the minibuffer and place it in
  76. Xthe current message's "expires:" header field.  Set the current
  77. Xmessage's "timely" attribute.  With a prefix argument, do not read a
  78. Xdate; instead, clear the current message's "timely" attribute and
  79. X"expires:" header field, no longer making it a candidate for automatic
  80. Xremoval.
  81. X
  82. XThe mail reader uses the "expires:" field described above to perform
  83. Xautomatic message removal.  When the user opens a folder, if the
  84. Xcurrent date is greater than the date on any message's expiration
  85. Xfield (if it has one), the mail reader applies the Emacs-Lisp
  86. Xhook expression pcmail-expiration-hook to the message, clears the
  87. Xmessage's "timely" attribute, and set its "expired" attribute.  The
  88. Xdefault pcmail-expiration-hook sets the expired message's "deleted"
  89. Xattribute so the next folder expunge destroys the message.
  90. X
  91. Xu: pcmail-undelete-previous-message
  92. X
  93. XLooking backward from and including the current message, clear the
  94. Xnearest deleted message's "deleted" attribute.
  95. X
  96. XESC C-u: pcmail-undelete-subset
  97. X
  98. XClear the "deleted" attribute of every deleted message in the current subset.
  99. X
  100. Xy: pcmail-change-message-attr
  101. X
  102. XPrompt for an attribute name and toggle that attribute of the current
  103. Xmessage.  Input completion is permitted; input defaults to last
  104. Xattribute given to an attribute command.  If the attribute supplied
  105. Xdoes not exist, offer to create it.  User-defined attributes are
  106. Xtherefore created simply by entering a name which the mail reader has
  107. Xnot seen before.  THe mail reader stored such attributes in the
  108. Xprimary folder's header and loads them whenever that folder is opened. 
  109. X
  110. XWith a prefix argument, don't toggle the attribute.  Instead, if the
  111. Xargument is positive, set the attribute; if negative, clear the
  112. Xattribute.  The mail reader pre-defines the following message
  113. Xattributes:
  114. X
  115. Xanswered               undigestified
  116. Xbadheader               unseen
  117. Xcopied                             deleted
  118. Xedited                             expired
  119. Xfiled                              forwarded
  120. Xprecious               printed
  121. Xrecent                             timely
  122. X
  123. XSpecial note needs to be made about the "precious" attribute.
  124. XMessages with the "precious" attribute cannot be deleted.  This
  125. Xprevents inadvertent deletion of important messages (for example by
  126. Xthe print, copy, and archive commands if the
  127. Xdelete-on{print,copy,archive} flags are set).
  128. X
  129. XThe "badheader" attribute is set on any mail-drop file which the mail
  130. Xreader cannot process because the collection's mail-drop format is
  131. Xincorrect for a mail-drop of that type.  In these cases the mail
  132. Xreader collects the file contents into a single message with a special
  133. Xheader, and sets the "badheader" attribute.
  134. X
  135. XESC C-y: pcmail-change-attr-subset
  136. X
  137. XAs above, but perform the attribute change on every message in the
  138. Xmessage subset.
  139. X
  140. Xz: pcmail-zap-to-message
  141. X
  142. XDelete all messages in the message subset starting with the current
  143. Xmessage and moving forward.
  144. X
  145. X
  146. X5.1.4 Mail Composition Commands
  147. X
  148. XThe following commands allow users to compose new messages, or reply
  149. Xto or forward existing messages.  Executing any composition command
  150. Xplaces the user in a message composition buffer and puts the buffer in
  151. XMail Mode.  See the GNU-Emacs Mail Mode documentation for details on
  152. Xcommands available in Mail Mode.
  153. X
  154. XPcmail implements a number of enhancements to Mail Mode whih overlay
  155. Xstandard Mail Mode commands on entry.  One of these is an augmented
  156. Xmessage-insert function.  Normal Mail Mode allows a user to insert the
  157. Xcurrent message text into a reply or forwarded message with an
  158. Xinsert-message function (keystrokes C-C C-Y).  The enhanced function,
  159. Xwhich supersedes the normal function, will insert any message N from
  160. Xthe current folder if the user supplies a prefix argument N to the
  161. Xinsert command.  If the "supercite" package's "mail-yank-hooks" hook
  162. Xvariable is set, the hook will be run, allowing incorporation of
  163. Xsupercite functionality.
  164. X
  165. XIf a message is inserted with the insert command, the default yank
  166. Xhook is used, and the variable pcmail-yank-prefix is set to a string,
  167. Xthen that string will preface each nonblank line of the inserted
  168. Xmessage.  This provides an easy way to specially highlight referenced
  169. Xmessages (with a ">" for example) within an outgoing message.
  170. X
  171. X
  172. X5.1.4.1  Mail Mode Configuration Variables
  173. X
  174. XPcmail makes use of a number of mail-composition mode configuration
  175. Xvariables.  Although they are fully described in the GNU-Emacs mail
  176. Xmode documentation, they are also defined here for completeness.
  177. X
  178. Xmail-header-separator
  179. X
  180. XThe text separating the message header from its body in the mail
  181. Xcomposition buffer.  Most users will not want to change this.  Default
  182. Xvalue is the string "-- text follows this line --".
  183. X
  184. Xmail-use-rfc822
  185. X
  186. XWhen replying to or forwarding a message, use a full NIC RFC-822
  187. Xparser to extract field information from the source messages.  Since
  188. Xthis is usually overkill, the default value for this variable is NIL.
  189. X
  190. Xmail-yank-ignored-headers
  191. X
  192. XWhen the pcmail-insert-current-message command inserts a message into
  193. Xthe message composisiton buffer, the default yank hook prunes the
  194. Xinserted message's headers by filtering them through the
  195. Xmail-yank-ignored-headers regular expression.  Default value is:
  196. X
  197. X "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^remailed\\|^received:\\|
  198. X  ^[a-z-]*message-id:\\|^summary-line:\\|^to:\\|^cc:\\|^subject:\\|
  199. X  ^in-reply-to:\\|^return-path:"
  200. X
  201. Xmail-default-reply-to:
  202. X
  203. XIf non-NIL, an address to insert as the default Reply-to field of outgoing
  204. Xmessages.  Default value is NIL.
  205. X
  206. Xmail-setup-hook:
  207. X
  208. XIf non-NIL, a hook expression evaluated on entry into the mail
  209. Xcomposition buffer.  The hook expression is typically used to insert
  210. Xcustom header fields into outgoing messages.  Default value is NIL.
  211. X
  212. Xmail-self-blind:
  213. X
  214. XIf non-NIL, you will be sent a BCC copy of every outgoing message.
  215. XDefault value is NIL.
  216. X
  217. Xmail-archive-file-name:
  218. X
  219. XIf non-NIL, each outgoing message will have an "FCC:" field which
  220. Xcauses the message to be appended to the file named by
  221. Xmail-archive-file-name before transmission.  The "FCC:" field is
  222. Xstripped before transmission and after archiving.
  223. X
  224. Xmail-aliases:
  225. X
  226. XIf non-NIL and not T, mail-aliases is an association list binding
  227. Xalias names to mail addresses.  The aliases can be placed in outgoing
  228. Xmessage "To:", "Cc:", and "Bcc:" fields and will be automatically
  229. Xexpanded on transmission.  If mail-aliases is T, read a ".mailrc" file
  230. Xand replace mail-aliases with an association list derived from the
  231. Xfile.  A ".mailrc" file consists of text lines of the form:
  232. X
  233. X    alias foo foo@oracle.com
  234. X
  235. X
  236. Xrmail-dont-reply-to-names:
  237. X
  238. XA regular expression describing addresses not to be included in the
  239. X"CC:" field of a message reply.  This prevents inadvertent reply CCs
  240. Xto mailing lists while enabling direct replies.  Note that this only
  241. Xaffects the contents of the mail composition buffer upon entry.  You
  242. Xcan add addresses at will once the composition buffer is entered.
  243. XDefault value is NIL, which means don't reply to yourself.
  244. X
  245. X
  246. X5.1.4.2 Mail Composition Commands
  247. X
  248. Xf: pcmail-forward-message
  249. X
  250. XForward the current message.  On entry to the composition buffer, the
  251. Xcomposed message header will already contain a "subject:" field
  252. Xderived from the forwarded message's header.  Insert the forwarded
  253. Xmessage in the composed message.  The inserted message's header is
  254. Xpruned according to the regular expression mail-yank-ignored-headers
  255. Xunless a prefix argument is supplied.  If
  256. Xpcmail-highlight-forwarded-message is non-NIL, bracket the inserted
  257. Xmessage text with "begin forwarded message" and "end forwarded
  258. Xmessage".  See the GNU-Emacs Mail Mode documentation for details on
  259. Xcommands available in Mail Mode.
  260. X
  261. XThe message's "forwarded" attribute is set after the message being
  262. Xcomposed is transmitted.  If the composed message is aborted for some
  263. Xreason, then the attribute is not set.
  264. X
  265. XNote that normal DARPA Internet RFC-822 mail addresses can be used in
  266. Xthe message header fields, even on VMS.  The system-dependent mail
  267. Xtransmission hooks will translate addresses to operating-system
  268. Xformat as required.
  269. X
  270. Xm, C-x m: pcmail-mail
  271. X
  272. XCompose a message in another window.  See the GNU-Emacs Mail Mode
  273. Xdocumentation for details on commands available in Mail Mode.
  274. X
  275. XNote that normal DARPA Internet RFC-822 mail addresses can be used in
  276. Xthe message header fields, even on VMS.  The system-dependent mail
  277. Xtransmission hooks will translate addresses to operating-system
  278. Xformat as required.
  279. X
  280. Xr: pcmail-answer-message
  281. X
  282. XReply to the current message.  On entry into the composition buffer,
  283. Xthe reply header will already contain "to:", "subject:", and
  284. X"in-reply-to:" fields derived from the replied-to message's message
  285. Xheader.  By default, all addresses in the original message's "to:" and
  286. X"cc:" header fields are CC'd in the reply.  To disable this feature,
  287. Xinvoke the reply command with a prefix argument.  If
  288. Xpcmail-yank-message-on-reply is non-NIL, place a copy of the
  289. Xreplied-to message in the body of the reply.  The inserted message is
  290. Xprocessed according to the hook variable mail-yank-hooks.  If such a
  291. Xhook has not been defined, a default hook is used; it indents the
  292. Xmessage, filters its headers according to mail-yank-ignored-headers,
  293. Xand prefaces nonblank lines with pcmail-yank-prefix if that variable
  294. Xis non-NIL.
  295. X
  296. XSee the GNU-Emacs Mail Mode documentation for more details on commands
  297. Xavailable in Mail Mode.
  298. X
  299. XThe message's "answered" attribute is set after the message being
  300. Xcomposed is transmitted.  If the composed message is aborted for some
  301. Xreason, then the attribute is not set.
  302. X
  303. XNote that normal DARPA Internet RFC-822 mail addresses can be used in
  304. Xthe message header fields, even on VMS.  The system-dependent mail
  305. Xtransmission hooks will translate addresses to operating-system
  306. Xformat as required.
  307. X
  308. X
  309. X5.1.5 Message Output Commands
  310. X
  311. Xa: pcmail-archive-message
  312. X
  313. XRead a file name from the minibuffer.  Input completion is permitted;
  314. Xinput defaults to the last file supplied to an archive command.
  315. XAppend the current message to the file.  If the variable
  316. Xpcmail-delete-on-archive is non-NIL, delete the message after
  317. Xarchiving and move to the next interesting message in the message
  318. Xsubset.  With a prefix argument, do not delete the message after
  319. Xarchiving no matter what the setting of pcmail-delete-on-archive.  Set
  320. Xthe message's "filed" attribute.
  321. X
  322. XESC C-a: pcmail-archive-subset
  323. X
  324. XAs above, but archive (and potentially delete after archiving) all
  325. Xmessages in the message subset.
  326. X
  327. Xc: pcmail-copy-message
  328. X
  329. XRead a folder name from the minibuffer and copy the current message
  330. Xto that folder.  Input completion is permitted; input defaults to
  331. Xthe name of the last folder given to a folder command.  If the
  332. Xvariable pcmail-delete-on-copy is non-NIL, delete the message after
  333. Xcopying and move to the next interesting message in the message
  334. Xsubset.  With a prefix argument, do not delete the message after
  335. Xcopying no matter what the setting of pcmail-delete-on-copy.  Set the
  336. Xmessage's "copied" attribute.
  337. X
  338. XESC C-c: pcmail-copy-subset
  339. X
  340. XAs above, but copy (and potentially delete after copying) all messages
  341. Xin the message subset.
  342. X
  343. Xo: pcmail-print-message
  344. X
  345. XRead a printer name from the minibuffer.  The deafult printer name is
  346. Xspecified by pcmail-default-printer-name.  Output the current message
  347. Xto the printer using an operating-system dependent print function.  If
  348. Xthe variable pcmail-delete-on-print is non-NIL, delete the message
  349. Xafter printing and move to the next interesting message in the message
  350. Xsubset.  With a prefix argument, do not delete the message after
  351. Xprinting no matter what the setting of pcmail-delete-on-print.  Set
  352. Xthe message's "printed" attribute.
  353. X
  354. XESC C-o: pcmail-print-subset
  355. X
  356. XAs above, but print (and potentially delete after printing) all
  357. Xmessages in the message subset.
  358. X
  359. X
  360. X5.1.6 Folder Modification Commands
  361. X
  362. XESC c: pcmail-create-folder
  363. X
  364. XCreate a new folder.  Read a folder name from the minibuffer.  The
  365. Xname must consist of valid folder name characters (typically
  366. Xalphanumerics and some punctuation, where the complete set of
  367. Xpunctuation permitted is operating-system dependent).  With a prefix
  368. Xargument, also read a mail drop name from the minibuffer and attach
  369. Xthat mail drop to the folder.  When the folder is opened with the
  370. Xpcmail-get-mail ("g") command, any new mail will automatically be
  371. Xtransferred from the attached mail drop to the folder.  Mail drop type
  372. Xcompletion is permitted; the mail drop defaults to the last mail drop
  373. Xsupplied to a mail drop command.
  374. X
  375. XESC d: pcmail-delete-folder
  376. X
  377. XWith a prefix argument, read a folder name from the minibuffer and
  378. Xdelete that folder, otherwise delete the current folder.  Input
  379. Xcompletion is permitted; input defaults to the name of the last
  380. Xfolder given to a folder command.  The primary folder may not be
  381. Xdeleted.  Note that the folder need not be empty for it to be
  382. Xdeleted, and that once deleted, the folder may not be able to be
  383. Xrecovered, depending on the underlying operating system.  Prompt for a
  384. X"yes" confirmation before deleting the folder.  Delete the folder
  385. Xfile, remove its entry in the folder list buffer, and kill any
  386. Xassociated GNU-Emacs folder and summary buffers.
  387. X
  388. Xe: pcmail-expunge-folder
  389. X
  390. XWith a prefix argument, read a folder name from the minibuffer and
  391. Xexpunge that folder, otherwise expunge the current folder.  Input
  392. Xcompletion is permitted; input defaults to the name of the last folder
  393. Xgiven to a folder command.  Remove all deleted messages from the
  394. Xfolder.  Change message numbers to fill any holes left by deleted
  395. Xmessages which were removed.  If pcmail-wastebasket-on-expunge is
  396. Xnon-NIL, copy deleted messages to the folder named by
  397. Xpcmail-wastebasket-folder before removing (this can be a
  398. Xtime-consuming operation).
  399. X
  400. Xg: pcmail-get-mail
  401. X
  402. XWith a prefix argument, read a folder name from the minibuffer and
  403. Xopen that folder, otherwise open the current folder.  Input completion
  404. Xis permitted; input defaults to the name of the last folder given to a
  405. Xfolder command.  If any mail drops are attached to the folder, use
  406. Xtheor import functions to transfer new mail from the mail drops to the
  407. Xfolder.  Display either the first unseen or the last interesting
  408. Xmessage in the folder.
  409. X
  410. Xh: pcmail-summarize-folder
  411. X
  412. XWith a prefix argument, read a folder name from the minibuffer and
  413. Xsummarize that folder, otherwise summarize the current folder.
  414. XInput completion is permitted; input defaults to the name of the last
  415. Xfolder given to a folder command.  Display a summary of the message
  416. Xsubset in another window and enter the other window.  The summary is
  417. Xplaced in Summary Mode; see the command listing under Summary Mode
  418. XCommands for available commands.
  419. X
  420. Xl: pcmail-load-mail-drop:
  421. X
  422. XRead a mail drop type from the minibuffer.  Read any mail
  423. Xdrop-dependent information from the minibuffer.  Use the mail drop's
  424. Ximport function to convert the mail drop's contents into
  425. XBabyl-formatted messages and add them to the current folder.
  426. XDepending on the mail drop type, delete the mail drop contents after
  427. Xincoporating them into the current folder.  Mail drop type completion
  428. Xis permitted; input defaults to the last mail drop type given this
  429. Xcommand.  Completion of mail drop-dependent information may also be
  430. Xpermitted (if the information requested is a file name, for example),
  431. Xdepending on the mail drop type.  In addition to standard
  432. Xoperating-system mail drops, the mail reader provides several other
  433. Xmail drop types.
  434. X
  435. X  babyl-mail-drop:
  436. X
  437. X  Import files containing messages in Babyl format, the format that
  438. X  both Pcmail and GNU-Emacs RMAIL use to store messages in a folder.
  439. X  The user specifies the file name; completion on input is permitted and
  440. X  input defaults to the file "RMAIL" in the user's home directory.
  441. X  The file is deleted after it is incorporated. 
  442. X
  443. X  vms-file-mail-drop:
  444. X
  445. X  Import files containing messages in VMS MAIL extraction format.  This
  446. X  is available on VMS systems only.  Messages from any folder in a VMS
  447. X  MAIL.MAI file can be transferred to a pcmail folder by extracting the
  448. X  messages into a file and invoking pcmail-load-mail-drop with mail drop
  449. X  type vms-file-mail-drop.  The user specifies the extract file name;
  450. X  completion on input is permitted and input defaults to the file
  451. X  "maildrop.log" in the user's mail directory.  The file is deleted after
  452. X  it is incorporated.
  453. X
  454. X  berkeley-mail-drop:
  455. X
  456. X  Import files in Berkeley Mail format.  The user specifies the mail
  457. X  file name; completion on input is permitted and input defaults to the
  458. X  file "mbox" in the user's home directory.  The file is deleted after
  459. X  it is incorporated.
  460. X
  461. X  nntp-mail-drop:
  462. X  nntp-file-mail-drop:
  463. X
  464. X  The first type uses the nntp_slave program to load all recent netnews
  465. X  messages from a newsgroup which has the same name as the current
  466. X  folder.  The second loads netnews messages which have been written
  467. X  to a file and then deletes that file.  The latter is very similar to
  468. X  berkeley-mail-drop, except that netnews headers are slightly
  469. X  different from ordinary mail headers 
  470. X
  471. X  mh-mail-drop:
  472. X
  473. X  Import a named MH folder's contents into the current folder.  The user
  474. X  specifies the MH folder name; completion on input is permitted (the
  475. X  available choices consist of all valid MH folders), although no
  476. X  default is provided.  Note that the MH folder directory and its
  477. X  message files are not deleted after incorporation.
  478. X
  479. X
  480. XESC m: pcmail-list-folders
  481. X
  482. XDisplay a list of folders in another window and enter that window.
  483. XThe list is placed in Folder List Mode; see the command listing under
  484. XFolder List Mode Commands for available commands.
  485. X
  486. XESC r: pcmail-rename-folder
  487. X
  488. XWith a prefix argument, read a folder name from the minibuffer and
  489. Xrename that folder, otherwise rename the current folder.  Input
  490. Xcompletion is permitted; input defaults to the name of the last
  491. Xfolder given to a folder command.  The primary folder may not be
  492. Xrenamed.  Read the new name from the minibuffer.
  493. X
  494. Xs: pcmail-save-folder
  495. X
  496. XWith a prefix argument, read a folder name from the minibuffer and
  497. Xsave that folder, otherwise save the current folder.  Input
  498. Xcompletion is permitted; input defaults to the name of the last
  499. Xfolder given to a folder command.  If pcmail-expunge-on-save is
  500. Xnon-NIL, expunge the folder before saving.
  501. X
  502. X
  503. X5.1.7 Miscellaneous Commands
  504. X
  505. Xb: pcmail-sort-folder
  506. X
  507. XSort the message subset by one of a number of keys.  Request a sort
  508. Xkey from the minibuffer.  Completion of input is permitted; input
  509. Xdefaults to the last sort key given this command.  The mail reader
  510. Xpre-defines four sort keys:
  511. X
  512. X  date:        sort the subset by increasing date, where the date
  513. X        used is the message's "date:" field.
  514. X
  515. X  priority:     sort the subset by decreasing priority (highest
  516. X        priority messages first) using the message's "priority:"
  517. X        field.  Messages with no priority default to being
  518. X        highest priority.
  519. X
  520. X  recipient:    sort the subset lexicographically by recipient name.
  521. X        If there is more than one recipient, sort by the first.
  522. X        Recipients default first to the "resent-to:" field, then
  523. X        "resent-apparently-to:", "to:", and "apparently-to:".
  524. X
  525. X  sender:       sort the subset lexicographically by sender name.
  526. X        Sender defaults first to the "resent-from:" field,
  527. X        then "resent-sender:", "from:", and "sender:".
  528. X
  529. XESC C-f: pcmail-filter-folder
  530. X
  531. XRead a filter name and associated arguments from the minibuffer.
  532. XInput completion is permitted; input defaults to the last filter name
  533. Xgiven to a filter command.  Completion may or may not be permitted on
  534. Xfilter arguments depending on the filter.  Apply the filter to each
  535. Xmessage in the current folder.  Messages which pass through the filter
  536. Xcomprise the current subset and become the only accessible messages in
  537. Xthe current folder.  If the resulting subset is empty, do nothing,
  538. Xotherwise replace the current message subset with the newly generated
  539. Xsubset.  Note that access to the entire folder can be gained by typing
  540. Xthe pcmail-expand-subset ("x") command.
  541. X
  542. XThe mail reader pre-defines the following filters; use the
  543. Xpcmail-define-filter Emacs-Lisp function to define custom filters.
  544. X
  545. Xaddress:    all messages with a specified address (or address
  546. X        fragment) in the message header's "to:", "from:", or
  547. X        "cc:" fields. 
  548. X
  549. Xall:        all messages
  550. X
  551. Xattribute:    all messages with a particular attribute.
  552. X
  553. Xdate-range:    all messages with header "date:" fields between two
  554. X        specified dates
  555. X
  556. Xinteresting:    all interesting messages, as determined by the hook
  557. X        expression pcmail-interesting-hook.
  558. X
  559. Xnumeric-range:  all messages between two specified absolute message
  560. X        numbers. 
  561. X
  562. Xstring:        all messages containing a specified string.
  563. X
  564. Xtodays:        all messages with a "date:" header field of today's
  565. X        date. 
  566. X
  567. Xunanswered:    all unanswered messages.
  568. X
  569. Xunseen:        all unseen messages.
  570. X
  571. X
  572. Xq: pcmail-quit
  573. X
  574. XExit the mail reader in an orderly manner.  If pcmail-save-on-quit is
  575. Xnon-NIL (default), save all open folders.  The save process may in
  576. Xturn expunge before saving, depending on the value of
  577. Xpcmail-expunge-on-save.  After saving, evaluate the Emacs-Lisp
  578. Xhook expression pcmail-exit-hook, and prompt for a new GNU-Emacs
  579. Xbuffer to switch to.  With a prefix argument, do not evaluate the exit
  580. Xhook. 
  581. X
  582. Xt: pcmail-toggle-message-header
  583. X
  584. XIf the full message header of the current message is displayed,
  585. Xreplace the full header by a pruned header containing no fields
  586. Xspecified in the list pcmail-uninteresting-fields-list.  If the pruned
  587. Xheader is displayed, replace it with the full message header.
  588. XMessages headers are by default pruned before a message is displayed;
  589. Xtypical pruned header fields are "received:", "message-id:", and
  590. X"summary-line:".  pcmail-uninteresting-fields-list contains the
  591. Xcomplete list of pruned header fields.
  592. X
  593. Xv: pcmail-version-information
  594. X
  595. XDisplay the mail reader version number and all current configuration
  596. Xvariable settings in another window.
  597. X
  598. Xw: pcmail-edit-message
  599. X
  600. XEdit the body of the current message.  Enter Edit Mode, which causes
  601. Xall Folder Mode commands to be superseded by standard GNU-Emacs Text
  602. XMode commands for the duration of the edit.  Edit Mode also provides
  603. Xtwo new commands for the duration of the edit: C-c C-c saves the edit
  604. Xand sets the message's "edited" attribute if the message was indeed
  605. Xchanged.  C-c C-] aborts the edit and restores the original message
  606. Xbody.  Both commands restore Folder Mode, re-enabling mail reader
  607. Xcommands.  The hook pcmail-edit-mode-hook is run when Edit Mode is
  608. Xentered. 
  609. X
  610. Xx: pcmail-expand-subset
  611. X
  612. XExpand the message subset to include all messages in the folder.  If
  613. Xthe current folder has been filtered, this is a fast way of
  614. Xregaining access to all messages in the folder.
  615. X
  616. XESC x pcmail-undigestify-message
  617. X
  618. XIf the current message is a UNIX Digest-format message, burst it into
  619. Xits constituent messages.  Append the messages to the current subset if
  620. Xthey pass the current folder filter.  Delete the digest and move to
  621. Xthe next interesting message in the message subset.  All constituent
  622. Xmessages automatically share the parent digest's attributes.  A
  623. Xforwarded message containing a digest is undigestified transparently .
  624. X
  625. X
  626. X
  627. X5.2 Folder List Mode Commands
  628. X
  629. XThe folder list buffer is always placed in Folder List Mode.  The
  630. Xbuffer contains a line of descriptive information about each existing
  631. Xfolder; the list is displayed from Folder Mode with the
  632. Xpcmail-list-folders ("ESC m") command.  Folder List Mode commands
  633. Xgenerally operate on the "current folder", which is the folder whose
  634. Xdescription is next to the cursor.  Each Folder List Mode command has
  635. Xa corresponding Folder Mode command; descriptions of Folder List
  636. XMode commands will be brief and will refer to the corresponding
  637. XFolder Mode commands.
  638. X
  639. X?: describe-mode
  640. X
  641. XDisplay a list of available commands and the keystrokes they are bound
  642. Xto.  Typing The GNU-Emacs Help key, followed by "k" or "f" will
  643. Xpresent documentation on functions by keystroke or function name,
  644. Xrespectively. 
  645. X
  646. X.: pcmail-folder-list-beginning-of-message
  647. X
  648. XOpen the folder next to the cursor and display its current message.
  649. X
  650. Xc: pcmail-folder-list-create-folder
  651. X
  652. XCreate a new folder.  See pcmail-create-folder.
  653. X
  654. Xd: pcmail-folder-list-delete-folder
  655. X
  656. XDelete the folder next to the cursor.  See pcmail-delete-folder.
  657. X
  658. Xe: pcmail-folder-list-expunge-folder
  659. X
  660. XExpunge the folder next to the cursor.  See pcmail-expunge-folder.
  661. X
  662. Xg, i: pcmail-folder-list-get-mail
  663. X
  664. XOpen the folder next to the cursor; if mail drops are attached to the
  665. Xfolder, get any new mail.  See pcmail-get-mail.
  666. X
  667. Xh: pcmail-folder-list-summarize-folder
  668. X
  669. XOpen the folder next to the cursor and display the folder and a
  670. Xsummary of its messages in another window.  See
  671. Xpcmail-summarize-folder and Summary Mode.
  672. X
  673. Xq: pcmail-quit
  674. X
  675. XExit the mail reader in an orderly manner.  See full information under
  676. XFolder Mode. 
  677. X
  678. Xr: pcmail-folder-list-rename-folder
  679. X
  680. XRename the folder next to the cursor.  See pcmail-rename-folder.
  681. X
  682. Xs: pcmail-folder-list-save-folder
  683. X
  684. XSave the folder next to the cursor.  See pcmail-save-folder.
  685. X
  686. Xx: pcmail-folder-list-exit
  687. X
  688. XExit the folder list display, returning to the current folder and
  689. Xdeleting the folder list window.
  690. X
  691. X
  692. X
  693. X5.3 Summary Mode
  694. X
  695. XThe summarize commands create a summary of the messages in a folder's
  696. Xmessage subset.  Each message has one line of information in the
  697. Xsummary.  The type of information that is displayed is controlled by
  698. Xthe configuration variable pcmail-summary-format.  See the section
  699. Xdescribing configuration variables for full information.  The default
  700. Xsummary format contains the message's number, "date:" field, "from:"
  701. Xfield, and "subject:" field, as well as a note whether the message is
  702. Xunseen or has been deleted.  The folder is placed in one Emacs window,
  703. Xthe summary in another.  Summaries are always placed in Summary Mode.
  704. XMany of the commands available in Folder Mode are also available in
  705. XSummary Mode; in cases where a particular Folder Mode command applies
  706. Xto the current message, the corresponding Summary Mode command applies
  707. Xto the message identified by the current summary line (the summary
  708. Xline where the cursor currently is located).  For simplicity's sake,
  709. Xthat message will be called the "current summary message".
  710. X
  711. XAny Summary Mode commands which change the number or order of messages
  712. Xin the summary (pcmail-expunge-folder, pcmail-get-mail,
  713. Xpcmail-filter-folder) will cause the folder to be automatically
  714. Xresummarized.
  715. X
  716. X
  717. X5.3.1 Getting Help
  718. X
  719. X?: describe-mode
  720. X
  721. XDisplay a list of available commands and the keystrokes they are bound
  722. Xto.  Typing The GNU-Emacs Help key, followed by "k" or "f" will
  723. Xpresent documentation on functions by keystroke or function name,
  724. Xrespectively. 
  725. X
  726. X
  727. X5.3.2 Movement Commands:
  728. X
  729. X>: pcmail-summary-last-message
  730. X
  731. XMove to the last interesting message in the summary and display it in
  732. Xthe other window.  With a prefix argument, move to the last message
  733. Xwhether or not it is interesting.
  734. X
  735. X<: pcmail-summary-first-message
  736. X
  737. XMove to the first message in the summary and display it in the other
  738. Xwindow. 
  739. X
  740. X.: pcmail-summary-beginning-of-message
  741. X
  742. XMove to the beginning of the current summary message.  Display that
  743. Xmessage in the other window if it is not already displayed.
  744. X
  745. XSPC: pcmail-summary-scroll-message-up
  746. X
  747. XDisplay the next page of the current summary message in the other
  748. Xwindow.
  749. X
  750. XDEL: pcmail-summary-scroll-message-down
  751. X
  752. XDisplay the previous page of the current summary message in the other
  753. Xwindow.
  754. X
  755. Xj: pcmail-summary-goto-message
  756. X
  757. XWith a prefix argument N, go to the Nth summary message and display it
  758. Xin the other window.  With no prefix argument, display the current
  759. Xsummary message in the other window.
  760. X
  761. Xn, RET: pcmail-summary-next-message
  762. X
  763. XMove to the next interesting message in the summary and display it.
  764. XSee pcmail-next-message. 
  765. X
  766. XESC n: pcmail-summary-next-message-of-type
  767. X
  768. XMove to the next message that satisfies a specified folder filter and
  769. Xdisplay it in the other window.  See pcmail-next-message-of-type
  770. X
  771. Xp: pcmail-summary-previous-message
  772. X
  773. XMove to the nearest previous interesting message in the summary and
  774. Xdisplay it in the other window.  See pcmail-previous-message.
  775. X
  776. XESC p: pcmail-summary-previous-message-of-type
  777. X
  778. XMove to the nearest previous message that satisfies a specified
  779. Xfolder filter and display it in the other window.  See
  780. Xpcmail-previous-message-of-type.
  781. X
  782. X
  783. X5.3.3 Attribute Modifying Commands:
  784. X
  785. Xd: pcmail-summary-delete-message
  786. X
  787. XDelete the current summary message, move to the next interesting
  788. Xsummary message, and display it in the other window.  See 
  789. Xpcmail-delete-message.
  790. X
  791. XC-d: pcmail-summary-delete-message-backward
  792. X
  793. XDelete the current summary message, move backward to the first
  794. Xinteresting message, and display it in the other window.  See
  795. Xpcmail-delete-message-backward
  796. X
  797. Xk: pcmail-summary-kill-message-later
  798. X
  799. XMake the current summary message expire at some point in the future.
  800. XSee pcmail-kill-message-later.
  801. X
  802. Xu: pcmail-summary-undelete-message
  803. X
  804. XSearching backward from and including the current summary message,
  805. Xundelete the first deleted message found and display it in the other
  806. Xwindow.  See pcmail-undelete-message
  807. X
  808. Xy: pcmail-summary-change-attr
  809. X
  810. XToggle an attribute of the current summary message.  See
  811. Xpcmail-change-attr.
  812. X
  813. X
  814. X5.3.4 Mail Composition Commands:
  815. X
  816. Xf: pcmail-summary-forward-message
  817. X
  818. XForward the current summary message.  See pcmail-forward-message.
  819. XNote that transmitting the message will not cause a return to the summary;
  820. Xit will return to the current message in the folder.
  821. X
  822. Xm: pcmail-summary-mail
  823. X
  824. XCompose a message in the other window.  See pcmail-mail.  Note that
  825. Xtransmitting the message will not cause a return to to the summary; it will
  826. Xreturn to the current message in the folder.
  827. X
  828. Xr: pcmail-summary-answer-message
  829. X
  830. XReply to the current summary message.  See pcmail-answer-message.
  831. XNote that transmitting the message will not cause a return to to the
  832. Xsummary; it will return to the current message in the folder.
  833. X
  834. X
  835. X5.3.5 Message Output Commands:
  836. X
  837. Xa: pcmail-summary-archive-message
  838. X
  839. XArchive the current summary message to a file.  See pcmail-archive-message.
  840. X
  841. Xc: pcmail-summary-copy-message
  842. X
  843. XCopy the current summary message to another folder.  See pcmail-copy-message. 
  844. X
  845. Xo: pcmail-summary-print-message
  846. X
  847. XPrint the current summary message.  See pcmail-print-message.
  848. X
  849. X
  850. X5.3.6 Folder Modification Commands:
  851. X
  852. Xe: pcmail-summary-expunge-folder
  853. X
  854. XExpunge the current folder, re-summarizing afterwards.  See
  855. Xpcmail-expunge-folder. 
  856. X
  857. Xg, i: pcmail-summary-get-mail
  858. X
  859. XTransfer any new mail from the current folder's mail drops,
  860. Xre-summarizing afterwards.  See pcmail-get-mail.
  861. X
  862. Xs: pcmail-summary-save-folder
  863. X
  864. XSave the current folder.  If pcmail-expunge-on-save is non-NIL,
  865. Xexpunge before saving and re-summarize.
  866. X
  867. X
  868. X5.3.7 Miscellaneous Commands:
  869. X
  870. Xb: pcmail-summary-sort-folder
  871. X
  872. XSort the current subset and generate an appropriate new summary,
  873. Xre-summarizing afterwards.  See pcmail-sort-folder.
  874. X
  875. XESC C-f: pcmail-summary-filter-folder
  876. X
  877. XFilter the current folder according to a user-specified filter,
  878. Xre-summarizing afterward.  See pcmail-filter-folder.
  879. X
  880. Xq: pcmail-summary-quit
  881. X
  882. XExit the mail reader in an orderly manner.  See pcmail-quit
  883. X
  884. Xw: pcmail-summary-edit-message
  885. X
  886. XEdit the body of the current summary message.  See
  887. Xpcmail-edit-message.
  888. X
  889. Xx: pcmail-summary-exit
  890. X
  891. XExit the summary, deleting the summary window and returning to the
  892. Xcurrent folder.
  893. ________This_Is_The_END________
  894. if test `wc -c < mailhelpab` -ne 32875; then
  895.     echo 'shar: mailhelpab was damaged during transit (should have been 32875 bytes)'
  896. fi
  897. fi        ; : end of overwriting check
  898. echo 'x - mh-to-pcmail-export'
  899. if test -f mh-to-pcmail-export; then echo 'shar: not overwriting mh-to-pcmail-export'; else
  900. sed 's/^X//' << '________This_Is_The_END________' > mh-to-pcmail-export
  901. X#!/bin/csh -f
  902. X# 
  903. X# GNU-EMACS PCMAIL mail reader support utility
  904. X
  905. X#  Written by Mark L. Lambert
  906. X#  Architecture Group, Network Products Division
  907. X#  Oracle Corporation
  908. X#  20 Davis Dr,
  909. X#  Belmont CA, 94002
  910. X#
  911. X#  internet: markl@oracle.com or markl%oracle.com@apple.com
  912. X#  UUCP:     {hplabs,uunet,apple}!oracle!markl
  913. X
  914. X# Copyright (C) 1989 Mark L. Lambert
  915. X
  916. X# This file is not officially part of GNU Emacs, but is being
  917. X# donated to the Free Software Foundation.  As such, it is
  918. X# subject to the standard GNU-Emacs General Public License,
  919. X# referred to below.
  920. X
  921. X# GNU Emacs is distributed in the hope that it will be useful,
  922. X# but WITHOUT ANY WARRANTY.  No author or distributor
  923. X# accepts responsibility to anyone for the consequences of using it
  924. X# or for whether it serves any particular purpose or works at all,
  925. X# unless he says so in writing.  Refer to the GNU Emacs General Public
  926. X# License for full details.
  927. X
  928. X# Everyone is granted permission to copy, modify and redistribute
  929. X# GNU Emacs, but only under the conditions described in the
  930. X# GNU Emacs General Public License.   A copy of this license is
  931. X# supposed to have been given to you along with GNU Emacs so you
  932. X# can know your rights and responsibilities.  It should be in a
  933. X# file named COPYING.  Among other things, the copyright notice
  934. X# and this notice must be preserved on all copies.
  935. X
  936. X# MH-to-pcmail exporter.  Takes two arguments: a folder name and an output
  937. X# file name (to hold the folder's concatenated messages).  Concatenates
  938. X# all messages in the folder into a single file, separated by regular 
  939. X# expression.  The folder directories are assumed to live in the standard
  940. X# MH folder directory ~/Mail/.
  941. X
  942. Xif ($#argv < 2) then
  943. X    echo "mh-to-pcmail-export: missing arguments"
  944. X    exit 1
  945. Xendif
  946. Xif (! -d ~/Mail ) then
  947. X    echo "mh-to-pcmail-export: no folder directory ~/Mail/"
  948. X    exit 1
  949. Xendif
  950. Xif (! -d ~/Mail/$1 ) then
  951. X    echo "mh-to-pcmail-export: no folder named $1"
  952. X    exit 1
  953. Xendif
  954. Xcd ~/Mail/$1
  955. X
  956. X# remove any old control files
  957. X#
  958. X#    export-filelist contains an unsorted list of shell commands
  959. X#        that will append messages to a message file
  960. X#    export-sorted-filelist is the numerically-sorted version of
  961. X#        the above, so messages are appended in numerical, not
  962. X#        lexicographic, order
  963. X#    export-message-separator is a file containing message separator text
  964. X
  965. Xif ( -e export-filelist ) rm export-filelist
  966. Xif ( -e export-sorted-filelist ) rm export-sorted-filelist
  967. Xif ( -e export-message-separator ) rm export-message-separator
  968. Xif ( -e $2 ) rm $2
  969. Xcat << END > export-message-separator
  970. X begin-message
  971. XEND
  972. X
  973. Xforeach mailfile ( [0-9]* )
  974. X    cat << bletch >> export-filelist
  975. Xcat export-message-separator $mailfile >> $2
  976. Xbletch
  977. Xend
  978. X
  979. X# sort the list of append commands
  980. X
  981. Xsort -n +2 -3 export-filelist > export-sorted-filelist
  982. X
  983. X# execute the append recursively (uck)
  984. X
  985. Xsource export-sorted-filelist
  986. X
  987. X# and clean up
  988. X
  989. Xrm export-filelist export-sorted-filelist export-message-separator
  990. ________This_Is_The_END________
  991. if test `wc -c < mh-to-pcmail-export` -ne 2910; then
  992.     echo 'shar: mh-to-pcmail-export was damaged during transit (should have been 2910 bytes)'
  993. fi
  994. fi        ; : end of overwriting check
  995. echo 'x - nntp.c'
  996. if test -f nntp.c; then echo 'shar: not overwriting nntp.c'; else
  997. sed 's/^X//' << '________This_Is_The_END________' > nntp.c
  998. X/*LINTLIBRARY*/
  999. X
  1000. X/*
  1001. X GNU-EMACS PCMAIL mail reader support utility
  1002. X
  1003. X Written by Mark L. Lambert
  1004. X Architecture Group, Network Products Division
  1005. X Oracle Corporation
  1006. X 20 Davis Dr,
  1007. X Belmont CA, 94002
  1008. X
  1009. X internet: markl@oracle.com or markl%oracle.com@apple.com
  1010. X UUCP:     {hplabs,uunet,apple}!oracle!markl
  1011. X
  1012. XCopyright (C) 1989 Mark L. Lambert
  1013. X
  1014. XThis file is not officially part of GNU Emacs, but is being
  1015. Xdonated to the Free Software Foundation.  As such, it is
  1016. Xsubject to the standard GNU-Emacs General Public License,
  1017. Xreferred to below.
  1018. X
  1019. XGNU Emacs is distributed in the hope that it will be useful,
  1020. Xbut WITHOUT ANY WARRANTY.  No author or distributor
  1021. Xaccepts responsibility to anyone for the consequences of using it
  1022. Xor for whether it serves any particular purpose or works at all,
  1023. Xunless he says so in writing.  Refer to the GNU Emacs General Public
  1024. XLicense for full details.
  1025. X
  1026. XEveryone is granted permission to copy, modify and redistribute
  1027. XGNU Emacs, but only under the conditions described in the
  1028. XGNU Emacs General Public License.   A copy of this license is
  1029. Xsupposed to have been given to you along with GNU Emacs so you
  1030. Xcan know your rights and responsibilities.  It should be in a
  1031. Xfile named COPYING.  Among other things, the copyright notice
  1032. Xand this notice must be preserved on all copies.
  1033. X*/
  1034. X
  1035. X/* NNTP client library */
  1036. X
  1037. X#include <stdio.h>
  1038. X#include "nntp.h"
  1039. X#include <sys/types.h>
  1040. X#include <sys/socket.h>
  1041. X#include <netinet/in.h>
  1042. X#include <netdb.h>
  1043. X#include <errno.h>
  1044. X
  1045. X/* local procedures */
  1046. Xint nntp_get_socket(), nntp_parse_response(), nntp_read(), nntp_getc();
  1047. Xvoid nntp_inc_ptr();
  1048. X
  1049. Xchar *nntp_errors[] = 
  1050. X{
  1051. X  "no error",
  1052. X  "I/O error",
  1053. X  "socket error",
  1054. X  "host not responding",
  1055. X  "service unavailable",
  1056. X  "host name unknown",
  1057. X  "connection reset by foreign host",
  1058. X  "protocol violation"
  1059. X};
  1060. X
  1061. Xchar *nntp_errstring(nnp)
  1062. X     register Nntp_stream *nnp;
  1063. X{
  1064. X  return(nntp_errors[nntp_errno(nnp)]);
  1065. X}
  1066. X
  1067. Xint nntp_open_connection(server, nnp)
  1068. X
  1069. Xchar *server;
  1070. Xregister Nntp_stream *nnp;
  1071. X{
  1072. X  memchr(nnp, 0, sizeof(Nntp_stream));                              /* zorch */
  1073. X  nnp->nn_new_data_begin = nnp->nn_old_data_begin = nnp->nn_inbuf;
  1074. X  nnp->nn_nbytes = 0;
  1075. X  if((nnp->nn_skt = nntp_get_socket(nnp, server)) == ERROR)
  1076. X    return(ERROR);
  1077. X  else if(nntp_in(nnp) == ERROR)                        /* get server banner */
  1078. X    goto CommErr;
  1079. X  else if(nntp_parse_response(nnp) == ERROR) 
  1080. X    goto CommErr;
  1081. X  return(OK);
  1082. X
  1083. X CommErr:
  1084. X  if(nnp->nn_skt) (void) close(nnp->nn_skt);
  1085. X  return(ERROR);
  1086. X}
  1087. X
  1088. Xint nntp_get_socket(nnp, host)
  1089. X     
  1090. Xregister Nntp_stream *nnp;
  1091. Xchar *host;
  1092. X{
  1093. X  int s;
  1094. X  struct sockaddr_in address;
  1095. X  struct servent *svc_info;
  1096. X  struct hostent *host_info;
  1097. X  
  1098. X  if(! (svc_info = getservbyname("nntp", "tcp"))) 
  1099. X  {
  1100. X    nnp->nn_error = NN_ERR_NOSVC;
  1101. X    return(ERROR);
  1102. X  }
  1103. X  else if(! (host_info = gethostbyname(host))) 
  1104. X  {
  1105. X    nnp->nn_error = NN_ERR_NOHOST;
  1106. X    return(ERROR);
  1107. X  }
  1108. X  memchr((char *) &address, 0, sizeof(address));
  1109. X  memcpy((char *) &(address.sin_addr), host_info->h_addr, host_info->h_length);
  1110. X  address.sin_family = host_info->h_addrtype;
  1111. X  address.sin_port = svc_info->s_port;
  1112. X  if((s = socket(host_info->h_addrtype, SOCK_STREAM, 0)) == ERROR) 
  1113. X  {
  1114. X    nnp->nn_error = NN_ERR_SKT;
  1115. X    return(ERROR);
  1116. X  }
  1117. X  else if(connect(s, &address, sizeof(address)) == ERROR) 
  1118. X  {
  1119. X    nnp->nn_error = NN_ERR_CONN;
  1120. X    return(ERROR);
  1121. X  }
  1122. X  else return(s);
  1123. X}
  1124. X
  1125. Xint nntp_out(nnp, str)
  1126. X
  1127. Xregister Nntp_stream *nnp;
  1128. Xregister char *str;
  1129. X{
  1130. X  register char *bptr = nnp->nn_outbuf;
  1131. X  register int nchrs;
  1132. X  register int len;
  1133. X
  1134. X  if(*str == '.' && strlen(str) > 1)             /* stuff a dot if necessary */
  1135. X    *bptr++ = '.';
  1136. X  memcpy(bptr, str, strlen(str));
  1137. X  bptr += strlen(str);
  1138. X  memcpy(bptr, "\r\n", 2);
  1139. X  bptr += 2;
  1140. X
  1141. X  /* we've stuffed the string into the output buffer,complete with dot-stuffing
  1142. X     and CRLF.  Now find length and reset bptr */
  1143. X  len = bptr - nnp->nn_outbuf;
  1144. X  bptr = nnp->nn_outbuf;
  1145. X  while(len)
  1146. X  {
  1147. X    if((nchrs = send(nnp->nn_skt, bptr, len, 0)) == ERROR)
  1148. X    {
  1149. X      if(errno == 0)
  1150. X        nnp->nn_error = NN_ERR_RESET;
  1151. X      else
  1152. X        nnp->nn_error = NN_ERR_IO;
  1153. X      return(ERROR);
  1154. X    }
  1155. X    bptr += nchrs;
  1156. X    len -= nchrs;
  1157. X  }
  1158. X  return(OK);
  1159. X}
  1160. X
  1161. X/* return 0 if end of list (dot by itself), 1 otherwise, -1 if error */
  1162. X
  1163. Xint nntp_in(nnp)
  1164. X
  1165. Xregister Nntp_stream *nnp;
  1166. X{
  1167. X  if(nntp_read(nnp) == ERROR)
  1168. X    return(ERROR);
  1169. X  if(nnp->nn_reply[0] == '.')                 /* de-stuff a dot if necessary */
  1170. X    if(strcmp(nnp->nn_reply, ".") == 0) return(0);
  1171. X    else if(nnp->nn_reply[1] == '.')
  1172. X      (void) strcpy(nnp->nn_reply, nnp->nn_reply + 1);
  1173. X  return(1);
  1174. X}
  1175. X
  1176. X/* return FALSE if the current server reply contains an error response, TRUE
  1177. X   else, ERROR if error */
  1178. X
  1179. Xint nntp_parse_response(nnp)
  1180. X
  1181. Xregister Nntp_stream *nnp;
  1182. X{
  1183. X  char reply_code[512];             /* protocol may lose, so use huge buffer */
  1184. X  
  1185. X  if(sscanf(nnp->nn_reply, "%s", reply_code) != 1) 
  1186. X  {
  1187. X    nnp->nn_error == NN_ERR_PROTO;
  1188. X    return(ERROR);
  1189. X  }
  1190. X  nnp->nn_reply_code = atoi(reply_code);
  1191. X  if(*reply_code == CHAR_ERR || *reply_code == CHAR_FATAL || 
  1192. X     *reply_code < CHAR_INF) 
  1193. X    return(FALSE);
  1194. X  return(TRUE);
  1195. X}
  1196. X
  1197. Xint nntp_command(nnp, msg)
  1198. X
  1199. Xregister Nntp_stream *nnp;
  1200. Xregister char *msg;
  1201. X{
  1202. X  if(nntp_out(nnp, msg) == ERROR) return(ERROR);
  1203. X  else if(nntp_in(nnp) == ERROR) return(ERROR);
  1204. X  else return(nntp_parse_response(nnp));
  1205. X}
  1206. X
  1207. Xvoid nntp_close(nnp)
  1208. X
  1209. Xregister Nntp_stream *nnp;
  1210. X{
  1211. X  (void) nntp_command(nnp, "QUIT");
  1212. X  if(nnp->nn_skt) (void) close(nnp->nn_skt);
  1213. X}
  1214. X
  1215. X/* read from the nntp server, if result is an end-of-list (dot by itself),
  1216. X   return TRUE else FALSE, ERROR if error */
  1217. Xint nntp_list_end_p(nnp)
  1218. X     register Nntp_stream *nnp;
  1219. X{
  1220. X  int endp;
  1221. X
  1222. X  if((endp = nntp_in(nnp)) == 0) return(TRUE);
  1223. X  else if(endp == 1) return(FALSE);
  1224. X  else return(ERROR);
  1225. X}
  1226. X
  1227. X/* read into an NNTP buffer, not including the carriage-return-newline pair
  1228. X   that terminate every NNTP command and response.  Assumes the supplied
  1229. X   buffer is at least 512 bytes long, since that is the maximum length of
  1230. X   an NNTP command/response.  This is gross since VMS won't let us use
  1231. X   stdio to do buffering.  Instead, we need to do our own buffering.  Ick. */
  1232. X
  1233. X#define NNTP_INC(nnp)  (nnp)->nn_new_data_begin++; (nnp)->nn_nbytes--;
  1234. X#define NNTP_NOCRLF 0
  1235. X#define NNTP_CR 1
  1236. X
  1237. Xint nntp_read(nnp)
  1238. X     register Nntp_stream *nnp;
  1239. X{
  1240. X  register char *bptr = nnp->nn_reply;
  1241. X  register int nchrs;
  1242. X  register int crlf_state = NNTP_NOCRLF;
  1243. X
  1244. X  while(TRUE)
  1245. X  {
  1246. X    if(nnp->nn_nbytes == 0)                        /* empty buffer?  Fill it */
  1247. X    {
  1248. X      nnp->nn_new_data_begin = nnp->nn_inbuf;
  1249. X      if((nchrs = recv(nnp->nn_skt, nnp->nn_inbuf, sizeof(nnp->nn_inbuf), 
  1250. X               0)) == ERROR)
  1251. X      {
  1252. X    if(errno != 0)
  1253. X          nnp->nn_error = NN_ERR_IO;
  1254. X        else
  1255. X          nnp->nn_error = NN_ERR_RESET;
  1256. X    return(ERROR);
  1257. X      }
  1258. X      nnp->nn_nbytes += nchrs;
  1259. X    }
  1260. X
  1261. X    /* look for CRLF */
  1262. X    while(nnp->nn_nbytes)
  1263. X    {
  1264. X      if(*(nnp->nn_new_data_begin) == '\r')
  1265. X      {
  1266. X    NNTP_INC(nnp);                                        /* punt the CR */
  1267. X    crlf_state = NNTP_CR;
  1268. X      }
  1269. X      else
  1270. X      {
  1271. X    if(crlf_state == NNTP_CR)
  1272. X    {
  1273. X      if(*(nnp->nn_new_data_begin) == '\n')
  1274. X      {
  1275. X        NNTP_INC(nnp);                                    /* punt the LF */
  1276. X        *bptr = '\0';
  1277. X        return(TRUE);
  1278. X      }
  1279. X      else
  1280. X      {
  1281. X        *bptr++ = '\r';                                    /* replace CR */
  1282. X      }
  1283. X    }
  1284. X    *bptr++ = *(nnp->nn_new_data_begin);
  1285. X    NNTP_INC(nnp);
  1286. X    crlf_state = NNTP_NOCRLF;
  1287. X      }
  1288. X    }
  1289. X  }
  1290. X}
  1291. ________This_Is_The_END________
  1292. if test `wc -c < nntp.c` -ne 7448; then
  1293.     echo 'shar: nntp.c was damaged during transit (should have been 7448 bytes)'
  1294. fi
  1295. fi        ; : end of overwriting check
  1296. exit 0
  1297.  
  1298.